<script type="text/javascript">
    function submitForm()
    {
        var maDanhMuc = $('#dropDownDanhMuc');    
        var tieude = $('#tieude'); 
        tieude.removeClass('text-warning');
        maDanhMuc.removeClass('text-warning');    
        var isValid = true;
        if(tieude.val() == '' || maDanhMuc.val() == '') 
        {
            if(tieude.val() == '') tieude.addClass('text-warning');  
            if(maDanhMuc.val() == '') maDanhMuc.addClass('text-warning');                      
            isValid = false;   
        }
        if(isValid) $('#frm').submit();
    }
</script>
<div class="top-bar">
    <h1><?php echo $info; ?></h1>
	<div class="breadcrumbs">
        <a href="#">Trang chủ</a> / <a href="#">Quản lý bài viết</a>/ <a href="#">Viết bài mới</a>
    </div>   
</div>

    <div class="table">
    <img src="<?php echo base_url('assets/imgs/admin/bg-th-left.gif') ?>" width="8" height="7" alt="" class="left" />
				<img src="<?php echo base_url('assets/imgs/admin/bg-th-right.gif')?>" width="7" height="7" alt="" class="right" />
        
        <form method="post" id="frm" action="<?php echo base_url('adcp/quanlybaiviet/themBaiVietMoi') ?>" enctype="multipart/form-data">
            <table class="listing form" cellpadding="0" cellspacing="0">
			<tr>
				<th class="full" colspan="2"></th>
			</tr>
			<tr>
				<td class="first" width="172"><strong>Tiêu đề (*)</strong></td>
				<td class="last"><input type="text" id="tieude" name="tieude" class="text" /></td>
			</tr>
			<tr class="bg">
				<td class="first"><strong>Danh mục (*)</strong></td>
				<td class="last">                
                    <select id="dropDownDanhMuc" name="dropDownDanhMuc">
                    <?php    
                        echo "<option value=''>--Chọn danh mục--</option>";                         
                        foreach($danhmuc as $row)
                        {
                            $madanhmuc = $row['madanhmuc'];
                            $tendanhmuc = $row['tendanhmuc'];
                            $danhmuccon = array();
                            $danhmuccon = $row['danhmuccon'];   
                            $countDanhMucCon = count($danhmuccon);                          
                            if($madanhmuc != "trangchu")
                            {
                                if($countDanhMucCon > 0)
                                {
                                    echo "<option value='root' disabled='disabled'>$tendanhmuc</option>"; 
                                    foreach($danhmuccon as $rowCon)
                                    {
                                        $madanhmuc_con = $rowCon['madanhmuc_con'];
                                        $tendanhmuc_con = $rowCon['tendanhmuc'];             
                                        echo "<option value='$madanhmuc-$madanhmuc_con'>&nbsp&nbsp&nbsp$tendanhmuc_con</option>";
                                    }
                                }
                                else 
                                {
                                    echo "<option value='$madanhmuc-'>$tendanhmuc</option>";   
                                }
                            }
                        }
                    ?>
                    </select>
                </td>
			</tr>
            <tr>
                <td class="first" width="172"><strong>Ảnh đại diện bài viết</strong> <br /></td>
                <td></td>				
            </tr>
            <tr class="bg">
                <td class="first" width="172">Upload <br /> <i>(.png, .bmp, .jpg)</i></td>
				<td class="last"><input type="file" id="uploadImage" class="uploadImage" name="uploadImage"/></td>
            </tr>		
            <tr>
                <td class="first" width="172">hoặc <input type="checkbox" id="chkInputLink" name="chkInputLink"/> Nhập đường dẫn <br /></td>
				<td class="last"><input type="text" id="linkimage" disabled="disabled" class="text linkimage" name="linkimage"/></td>
            </tr>
		</table>
            <textarea name="editor" id="editor" rows="30" cols="80"></textarea>
            <script>                
                CKEDITOR.replace('editor', {
                	language: 'vi'
                });
                
            </script>                        
             <button id="btnSubmit" onclick="submitForm()">
                    <img src="<?php echo base_url('assets/imgs/admin/save-icon.gif') ?>"/>
                    <label style="vertical-align: top;">Đăng bài mới</label>
             </button> 
        </form>
</div>